package com.acwer.domain.sys;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang3.StringUtils;

import com.acwer.framework.data.ColumnExplain;
import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName(value = "sys_user") // 指定表名
public class SysUser {

	@ColumnExplain(value = "主键", ls = false, isEdit = false)
	@TableId(value = "user_id", type = IdType.AUTO)
	private Long id;

	@ColumnExplain(value="登录帐号",search=true,required=true)
	@TableField(value = "account_id", exist = true)
	private String accountId;

	@ColumnExplain(value="姓名",search=true,required=true)
	private String name;

	@ColumnExplain(value = "出生日期", dataType = "date")
	private String birthday;

	@ColumnExplain(value = "性别", dataType = "dic", dataTokens = { "gender" })
	private String sex;

	@ColumnExplain("邮箱")
	private String email;

	@ColumnExplain("电话")
	private String phone;

	@ColumnExplain("状态")
	private String status;

	@ColumnExplain(value = "头像",ls=false, dataType = "upload")
	private String avatar;

	@ColumnExplain(value="未知(salt)",ls=false)
	private String salt;

	@ColumnExplain(value = "密码", dataType = "password",ls=false,required=true)
	private String password;

	@ColumnExplain(value="角色",ls=false,isEdit=false)
	public List<String> getRoles() {
		List<String> ls = new ArrayList<String>();
		if (StringUtils.isNotBlank(this.getRole())) {
			ls = Arrays.asList(getRole().split(","));
		}
		return ls;
	};

	@ColumnExplain(value="角色",dataType="sysrole")
	@TableField(value = "role_id", exist = true)
	private String role;

	@ColumnExplain("部门")
	@TableField(value = "dept_id", exist = true)
	private String deptId;

	@ColumnExplain(value="创建日期",ls=false,isEdit=false)
	@JSONField(format = "yyyy-MM-dd HH:mm:ss")
	@TableField(value = "create_time", exist = true)
	private Date createTime;

	@ColumnExplain(value="创建用户",ls=false,isEdit=false)
	@TableField(value = "create_user", exist = true)
	private String createUser;

	@ColumnExplain(value="修改日期",ls=false,isEdit=false)
	@JSONField(format = "yyyy-MM-dd HH:mm:ss")
	@TableField(value = "update_time", exist = true)
	private Date updateTime;

	@ColumnExplain(value="修改用户",ls=false,isEdit=false)
	@TableField(value = "update_user", exist = true)
	private String updateUser;
}
